package org.jeecg.modules.business.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.business.entity.BusBookingRooms;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.business.vo.ExtendBusBookingRoomsVo;

/**
 * @Description: 预定订单关联房间
 * @Author: jeecg-boot
 * @Date:   2023-03-25
 * @Version: V1.0
 */
public interface BusBookingRoomsMapper extends BaseMapper<BusBookingRooms> {
    @Select("SELECT " +
            "r.*, " +
            "l.`name` AS layoutName,  " +
            "l.`market_price`,  " +
            "rm.`name` as roomName  " +
            "FROM " +
            "bus_booking_rooms r  " +
            "INNER JOIN ces_room_layout l ON r.room_layout_id = l.id  " +
            "LEFT JOIN ces_rooms rm ON r.room_id = rm.id  " +
            "WHERE " +
            "r.booking_orders_id = #{bookingId} and " +
            "r.booking_type=#{sType}")
    List<ExtendBusBookingRoomsVo> bookingRooms(String bookingId, Integer sType);

    @Update("update bus_booking_rooms set is_main = 0 where booking_orders_id = #{orderId}")
    Boolean setNotMain(String orderId);

    @Select("<script>select bbr.*, cr.name as rooms_name ,cr.living_order_id from bus_booking_rooms bbr " +
            "left join ces_rooms cr on bbr.room_id = cr.id " +
            "where bbr.booking_orders_id in" +
            "<foreach item='id' collection='booingIds' open='(' separator=',' close=')'> " +
            "#{ id } </foreach> </script>")
    List<BusBookingRooms> bookingRoomsDetail(List<String> booingIds);
}
